<?php
/*
Template Name: Noticias
*/
?>

<?php get_header(); ?>
<body <?php body_class("bg_0"); ?>>
<div id="container">
	<?php include("wp-content/themes/coalhadas/menutopo.php"); ?>
    <div id="content">
        <div id="boxG" class="borda_redonda">
            <div id="noticia" class="jScrollbar3" style="margin-left:0;">
            	<div class="jScrollbar_mask" style="width:557px; float:left; font-size:15px; top:0px;">
                	<?php 
						if (isset($_GET['po']))
						{
							$categoria = get_the_category($_GET['po']);
							if ($categoria[0]->cat_ID == '5')
							{
							$post_getado = get_post($_GET['po']);
							?>
                    <h1><?php echo $post_getado->post_title; ?> <?php echo $post_getado->ID; ?></h1>
                    <div id="divisoria_horizontal_noticia" style="width:100%; height:2px; margin-top:-19px; margin-bottom:17px; background-color: #006bb7;"></div>
                    <?php echo $post_getado->post_content;
							}
							else
							{
							?>
                            Este post não é de uma notícia.
                            <?php	
							}
						}
						else
						{
						global $post;
						$myposts = get_posts('numberposts=1&category=5&order=dsc');
						foreach($myposts as $post) :
						setup_postdata($post);
					?>
                    <h1><?php the_title(); ?></h1>
                    <div id="divisoria_horizontal_noticia" style="width:100%; height:2px; margin-top:-19px; margin-bottom:17px; background-color: #006bb7;"></div>
						<?php the_content();
                        endforeach;
						} ?>  
                </div><!--jScrollbar_mask-->
                <div class="jScrollbar_draggable">
                    <!-- slider -->
                    <a href="#" class="draggable ui-draggable"></a>
                </div>
                <div class="clr"></div>
            </div><!-- noticia -->
            <div id="divisoria_vertical_noticia" style="float:left; width:2px; height:420px; background-color: #006bb7;"></div>
            <div id="noticia-sidebar" class="jScrollbar3" style="padding:0; width:213px;">
                <div class="jScrollbar_mask" style="width:180px; float:left; font-size:15px; top:0px; padding-left: 10px;">
                    <h3>Outras Notícias</h3>
                    <?php
						$paginado = '1';
						if (isset($_GET['paged']))
						{
							$paginado = ''.$_GET['paged'];
						} 
						global $post;
						$myposts = get_posts('category=5&order=dsc&paged='.$paginado);
						foreach($myposts as $post) :
						setup_postdata($post);
					?>
                    	<p><?php the_title(); ?></p>
                    	<a href="?page_id=70<?php echo '&po='; echo get_the_ID(); if (isset($_GET['paged'])){ echo '&paged='.$_GET['paged']; } ?>">Leia mais...</a>
                    <?php
                        endforeach;
					?>
                    
                </div><!--jScrollbar_mask-->
                <div class="jScrollbar_draggable">
                    <!-- slider -->
                    <a href="#" class="draggable ui-draggable"></a>
                </div>
                <div class="clr"></div>
             </div><!-- noticia-sidebar -->
        </div><!--empresa-box-->
    </div><!--content-->
<?php get_footer(); ?>